//
//  CQBaseNavigationController.m
//  CQFramework
//
//  Created by Martin on 16/5/21.
//  Copyright © 2016年 caoqin. All rights reserved.
//

#import "CQBaseNavigationController.h"

@interface CQBaseNavigationController ()

@end

@implementation CQBaseNavigationController


-(instancetype)initWithRootViewController:(UIViewController *)rootViewController{
    
        CQBaseNavigationController* nvc = [super initWithRootViewController:rootViewController];
        self.interactivePopGestureRecognizer.delegate = self;
        nvc.delegate = self;
        return nvc;

}

-(void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if (navigationController.viewControllers.count == 1)
        self.currentShowVC = Nil;
    else
        self.currentShowVC = viewController;
}

-(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
    if (gestureRecognizer == self.interactivePopGestureRecognizer) {
        return (self.currentShowVC == self.topViewController);
    }
    return YES;
}

+(void)cqSetNavigationBarTransparent:(UIViewController *)vc IsTransparent:(BOOL)transparent{
    UIImage *bgImg = nil;
    if (transparent) {
        bgImg = [UIImage new];
    }
    //导航栏背景透明
    [vc.navigationController.navigationBar setBackgroundImage:bgImg forBarMetrics:UIBarMetricsDefault];
    //底部那条线透明
    vc.navigationController.navigationBar.shadowImage = bgImg;
}

/**为了让该navgationController下的每一个VC都可以获得更改statusBar的权利*/
-(UIViewController *)childViewControllerForStatusBarStyle{
    return self.topViewController;
}

@end
